import java.util.Scanner;
public class Demo1 {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入一个数字n:");
        int n = sc.nextInt();
//计算n!
//        int chengji=1;
//        int i = 1;
//        while(i<=n){
//            chengji *=i;
//            i++;
//        }
//        System.out.println(chengji);

//计算1！+2！+3！+4！+5！+...+n!
        int sum = 0;
        int k =1;
        while(k<=n){
            int chengji =1;
            int i = 1;
            while(i<=k){
                chengji *= i;
                i++;
            }
            sum += chengji;
            k++;
        }
        System.out.println("1~"+n+"阶乘和为"+sum);
        sc.close();
    }
}